package o;

import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appmarket.framework.coreservice.DataHolder;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailHiddenBean;
import com.huawei.appmarket.service.distribution.batchdownload.bean.AppDetailInfo;
import com.huawei.appmarket.service.externalservice.distribution.download.request.BatchDownloadIPCRequest;
import com.huawei.appmarket.service.externalservice.distribution.download.request.DownloadInfo;
import com.huawei.hms.framework.common.ContainerUtils;

public class dxj {
    public static boolean ˋ(Context context, String str, String str2) {
        try {
            if (context.getPackageManager().getPackageInfo(str, 0).versionCode < Integer.parseInt(str2)) {
                return false;
            }
            return true;
        } catch (NameNotFoundException e) {
            Logger.ˎ("AgdBatchDownloadUtil", "can not find local installed package: " + str);
            return false;
        } catch (NumberFormatException e2) {
            Logger.ˎ("AgdBatchDownloadUtil", "parse versioncode error: NumberFormatException," + str2);
            return false;
        }
    }

    public static boolean ॱ(SessionDownloadTask sessionDownloadTask, String str, String str2) {
        Object ॱˎ = sessionDownloadTask.ॱˎ("mediaPkg");
        Object ॱˎ2 = sessionDownloadTask.ॱˎ("callerPkg");
        return (!TextUtils.isEmpty(ॱˎ) && ॱˎ.equals(str)) || (!TextUtils.isEmpty(ॱˎ2) && ॱˎ2.equals(str2));
    }

    public static void ˊ(SessionDownloadTask sessionDownloadTask, DataHolder<BatchDownloadIPCRequest> dataHolder, DownloadInfo downloadInfo) {
        if (TextUtils.isEmpty(dataHolder.ˏ().ˋ())) {
            sessionDownloadTask.ˎ("mediaPkg", null);
        } else {
            sessionDownloadTask.ˎ("mediaPkg", dataHolder.ˏ().ˋ());
        }
        if (TextUtils.isEmpty(downloadInfo.ˏ())) {
            sessionDownloadTask.ˎ("referrer", null);
        } else {
            sessionDownloadTask.ˎ("referrer", dof.ˎ(downloadInfo.ˏ()));
        }
        if (TextUtils.isEmpty(downloadInfo.ˋ())) {
            sessionDownloadTask.ˎ("advInfo", null);
        } else {
            sessionDownloadTask.ˎ("advInfo", downloadInfo.ˋ());
        }
        sessionDownloadTask.ˎ("advPlatform", String.valueOf(((BatchDownloadIPCRequest) dataHolder.ˊ()).ˋ()));
        sessionDownloadTask.ˎ("contentId", ((BatchDownloadIPCRequest) dataHolder.ˊ()).ॱ());
        sessionDownloadTask.ˎ("callerPkg", dataHolder.ˏ().ˏ());
        sessionDownloadTask.ˎ("downloadFlags", String.valueOf(((BatchDownloadIPCRequest) dataHolder.ˊ()).ˎ()));
    }

    public static DetailHiddenBean ॱ(AppDetailInfo appDetailInfo) {
        DetailHiddenBean detailHiddenBean = new DetailHiddenBean();
        detailHiddenBean.ˏˎ(appDetailInfo.ˋ());
        detailHiddenBean.ͺ(appDetailInfo.ʻ());
        detailHiddenBean.ॱᐝ(appDetailInfo.ॱ());
        detailHiddenBean.ˏॱ(appDetailInfo.ʼ());
        detailHiddenBean.ˋॱ(appDetailInfo.ᐝ());
        detailHiddenBean.ॱ(appDetailInfo.ॱॱ());
        detailHiddenBean.ˋ(appDetailInfo.ʽ());
        detailHiddenBean.ˉ(appDetailInfo.ˋॱ());
        detailHiddenBean.ˋᐝ(appDetailInfo.ˊॱ());
        detailHiddenBean.ॱ(appDetailInfo.ͺ());
        detailHiddenBean.ˎ(appDetailInfo.ˏॱ());
        return detailHiddenBean;
    }

    public static String ॱ(@NonNull DataHolder<BatchDownloadIPCRequest> dataHolder, DownloadInfo downloadInfo) {
        StringBuilder stringBuilder = new StringBuilder();
        if (!TextUtils.isEmpty(dataHolder.ˏ().ˋ())) {
            stringBuilder.append("mediaPkg=").append(dataHolder.ˏ().ˋ()).append(ContainerUtils.FIELD_DELIMITER);
        }
        if (!TextUtils.isEmpty(downloadInfo.ˏ())) {
            stringBuilder.append("referrer=").append(dof.ˎ(downloadInfo.ˏ())).append(ContainerUtils.FIELD_DELIMITER);
        }
        if (!TextUtils.isEmpty(downloadInfo.ˋ())) {
            stringBuilder.append("advInfo=").append(downloadInfo.ˋ()).append(ContainerUtils.FIELD_DELIMITER);
        }
        stringBuilder.append("advPlatform=").append(((BatchDownloadIPCRequest) dataHolder.ˊ()).ˋ()).append(ContainerUtils.FIELD_DELIMITER);
        stringBuilder.append("contentId=").append(((BatchDownloadIPCRequest) dataHolder.ˊ()).ॱ()).append(ContainerUtils.FIELD_DELIMITER);
        stringBuilder.append("callerPkg=").append(dataHolder.ˏ().ˏ()).append(ContainerUtils.FIELD_DELIMITER);
        stringBuilder.append("downloadFlags=").append(((BatchDownloadIPCRequest) dataHolder.ˊ()).ˎ());
        return stringBuilder.toString();
    }
}
